﻿#if NET35

//为接口统一,定义与 netstandard2.0环境下Microsoft.Extensions.Logging.ILogger 相同的接口及操作 

namespace Kernelx.Common.Logging
{

    /// <summary>
    ///  Identifies a logging event. The primary identifier is the "Id" property, with
    ///  the "Name" property providing a short description of this type of event.
    /// </summary>
    public readonly struct EventId
    {

        /// <summary>
        /// 
        /// </summary>
        public int Id { get; }


        /// <summary>
        /// Gets the name of this event.
        /// </summary>
        public string Name { get; }

        /// <summary>
        ///  Implicitly creates an EventId from the given System.Int32.
        /// </summary>
        /// <param name="i"> The System.Int32 to convert to an EventId.</param>
        public static implicit operator EventId(int i) => new EventId(i);

        /// <summary>
        /// Checks if two specified Microsoft.Extensions.Logging.EventId instances have the
        /// same value. They are equal if they have the same Id.
        /// </summary>
        /// <param name="left">The first Microsoft.Extensions.Logging.EventId.</param>
        /// <param name="right">The second Microsoft.Extensions.Logging.EventId.</param>
        /// <returns>  true if the objects are equal.</returns>
        public static bool operator ==(EventId left, EventId right) => left.Equals(right);

        /// <summary>
        /// Checks if two specified Microsoft.Extensions.Logging.EventId instances have different
        /// values.
        /// </summary>
        /// <param name="left"> The first Microsoft.Extensions.Logging.EventId.</param>
        /// <param name="right"> The second Microsoft.Extensions.Logging.EventId.</param>
        /// <returns>true if the objects are not equal.</returns>
        public static bool operator !=(EventId left, EventId right) => !left.Equals(right);

        /// <summary>
        /// Initializes an instance of the Microsoft.Extensions.Logging.EventId struct.
        /// </summary>
        /// <param name="id"> The numeric identifier for this event.</param>
        /// <param name="name">The name of this event.</param>
        public EventId(int id, string name = null)
        {
            Id = id;
            Name = name;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString() => Name ?? Id.ToString();

        /// <summary>
        ///  Indicates whether the current object is equal to another object of the same type.
        ///  Two events are equal if they have the same id.
        /// </summary>
        /// <param name="other"> An object to compare with this object.</param>
        /// <returns> true if the current object is equal to the other parameter; otherwise, false.</returns>
        public bool Equals(EventId other) => Id == other.Id;


        /// <summary>
        /// 
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj) => obj != null && ((obj is EventId other) && Equals(other));

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode() => Id;
    }


}
#endif